package com.naire.modul.template.service;

import net.common.service.GeneralService;

import com.naire.modul.questionnaire.service.QuestionnaireCreateService;
import com.naire.modul.template.dao.TemplateDao;
import com.naire.modul.template.dao.impl.TemplateDaoImpl;
import com.naire.modul.template.vo.TemplateVo;

/**
 * 
 * 
 * @author Administrator
 * 
 */
public class TemplateEditorService extends GeneralService {

	private Integer project_id;
	
	@Override
	public void execute() throws Exception {
		QuestionnaireCreateService service = new QuestionnaireCreateService();
		service.setProject_id(project_id);
		service.execute();
		String doc = service.getDoc();
		// 模板
		TemplateDao dao = new TemplateDaoImpl();
		TemplateVo vo = dao.find(project_id);
		if(vo == null) {
			vo = new TemplateVo();
		}
		vo.setTemplate(doc);
		vo.setProject_id(project_id);
		if(vo.getTemplate_id() != null) {
			dao.update(vo);
		} else {
			dao.insert(vo);
		}
	}

	public void setProject_id(Integer project_id) {
		this.project_id = project_id;
	}

}
